/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package eventxmlparser;

import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

/**
 *
 * @author krist_000
 */
public class EventXMLParser {

    /**
     * @param args the command line arguments
     */
    private static final String XML_PATH = "./ContextAwareModel.xml";
    private static final String XML_PATH1 = "./ContextAwareModel1.xml";
    private static final String XML_PATH_TIME = "./ContextAwareModelTime.xml";

    public static void main(String[] args) {

//        ArrayList<TimeTable> timeTableList = new ArrayList<TimeTable>();
//        ArrayList<Event> eventList = new ArrayList<Event>();
//        // create books
//        TimeTable timetable1 = new TimeTable();
//        timetable1.setId("Time 1");
//        timetable1.setFrom("2014-03-30");
//        timetable1.setTo("2016-06-20");
//        DayTime mon = new DayTime();
//        mon.setDay("monday");
//        mon.setStartTime("00:00");
//        mon.setDay("monday");
//        mon.setEndTime("10:00");
//        ArrayList<DayTime> days = new ArrayList<>();
//        days.add(mon);
//        timetable1.setDays(days);
//        timeTableList.add(timetable1);
//
//        TimeTable timetable2 = new TimeTable();
//        timetable2.setId("Time 2");
//        timetable2.setFrom("2012-03-30");
//        timetable2.setTo("2015-06-20");
//        timeTableList.add(timetable2);
//
//        Event event = new Event();
//        Transition trans = new Transition();
//        ArrayList<Transition> transList = new ArrayList<>();
//        TransitionDestination transDest = new TransitionDestination();
//        transDest.setRadius(1);
//        transDest.setRoomAreaID("area1");
//        transDest.setTimeTable("timetable1");
//        transDest.setTolerance(3);
//        trans.setFrom(transDest);
//        TransitionDestination transDest1 = new TransitionDestination();
//        transDest1.setRoomAreaID("room2");
//        transDest1.setTimeTable("timetable1");
//        trans.setTo(transDest1);
//        transList.add(trans);
//        event.setTransitions(transList);
//        event.setId("e2");
//        eventList.add(event);
//
//        // create bookstore, assigning book
//        ContextAwareModel ctx = new ContextAwareModel();
//        ctx.setTimeTables(timeTableList);
//        ctx.setEvents(eventList);

        Serializer serializer = new Persister();
        File source = new File(XML_PATH_TIME);
        try {
            ContextAwareModel example = serializer.read(ContextAwareModel.class, source);
            example.getTimeTables().get(0).evaluateTime(new Date());
            
            int i = 1;
        } catch (Exception ex) {
            Logger.getLogger(EventXMLParser.class.getName()).log(Level.SEVERE, null, ex);
        }


    }

}
